package com.xjtu.platform.user.admin.visit_arrange.dao;

import com.xjtu.platform.common.model.User;
import com.xjtu.platform.user.consultor.visitRecord.RecordModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @创建人 MBY381
 * @创建时间 2022/7/2 09:39
 * @描述 暂无
 */


@Mapper
public interface AdminDao {

    @Select("select visit_id,user_name,user.user_id as student_id,grade,expect_time,email,status,description " +
            "from user,first_visit " +
            "where user.user_id=first_visit.student_id " +
            "and status='arrangement' order by grade desc")
    List<RecordModel> getPage();


    @Select("select a.user_id as user_id,a.user_name as user_name,a.email as email,a.user_age as user_age " +
            " from user as a,user_role as b " +
            " where a.user_id=b.user_id and b.role_id = 'consultor' " +
            " and a.user_id not in (select distinct(visiter_id) from first_visit where visiter_id is not null and (status='visiting' or status ='consulting') )")

    List<User> getFreeConsultant();



    @Update("update first_visit set visiter_id =#{user_id},status='visiting' where student_id = #{student} and status ='arrangement'")
    void updateArrange(@Param("user_id") String user_id, @Param("student") String student);


    @Select("select email from user where user_id=#{id}")
    String findEmailByID(@Param("id") String user_id);
}
